package uml.class_diagram.validate;

import uml.class_diagram.warninfo.WarnInfo;

public class DefaltInputArgsValidator implements IInputArgsValidator {
	
	private String firstOption = "-bc";
	
	private String [] second = {"2","4","8","16"};

	public boolean validate(String[] args) {
		
		if (args == null || args.length != 4) {
			
			WarnInfo.warnDoc();
			return false;
		}
		
		if (!(args[0] == firstOption || firstOption.equals(args[1]))) {
			
			WarnInfo.warnDoc();
			return false;
		}
		
		try {
			
			if (args[2].length()>18) {
				throw new IllegalArgumentException(args[2] + "值过大！");
			}
			Long.parseLong(args[2]);
		} catch (Exception e) {
			WarnInfo.errorPara(2,e);
			return false;
		}
		
		boolean contians = false;
		for (String string : second) {
			if (string == args[3] || string.equals(args[3])) {
				contians = true;
			}
		}
		
		if (!contians) {
			WarnInfo.errorPara(3, "参数需在:" + "{2,4,8,16}" + "范围内！");
			return false;
		}
		
		
		
		return true;
	}

}
